#ifndef __Scene_RenderQueue_h__
#define __Scene_RenderQueue_h__

#include "RenderOperation.h"

#include <vector>

namespace Orca {

	class Material;
	class GfxDriver;

	//--------------------------------------------------------------------------
	struct RenderSlot {

		Material *mtl;
		RenderOperation *rop;
		float viewDist;
	};
	
	//--------------------------------------------------------------------------
	class IRenderQueueSorter {

	public:
		virtual ~IRenderQueueSorter() {}
		virtual bool compare(const RenderSlot &lhs, const RenderSlot &rhs) = 0;
	};

	//--------------------------------------------------------------------------
	class RenderQueue {

	public:
		RenderQueue(uint16 id, IRenderQueueSorter *sorter);
		~RenderQueue();
		
		uint16 getId() const;

		void append(Material *mtl, RenderOperation *rop, float viewDist);
		void reset();
		void render(GfxDriver *gfxDriver);

	private:
		typedef std::vector<RenderSlot> RenderSlotList;
		RenderSlotList mSlotList;

		IRenderQueueSorter *mSorter;
		uint16 mId;
		
		struct RenderQueueCompare {

			IRenderQueueSorter *mSorter;

			bool operator() (const RenderSlot &lhs, const RenderSlot &rhs) {

				return mSorter->compare(lhs, rhs);
			}

		};

		void _sortRenderSlotList();
	};
}

#endif	// __Scene_RenderQueue_h__